package aobing;

import java.util.PriorityQueue;

/**
 * ThreadTeat
 *
 * @author Syzer
 * @Description
 * @Date 2021/6/26 0:59
 */
public class ThreadTeat {

    private static void test() throws InterruptedException {
        ThreadLocal<String> thread = new ThreadLocal<>();
        ThreadLocal<String> inheritableThreadLocal = new InheritableThreadLocal<>();

        thread.set("不恰");
        inheritableThreadLocal.set("帅得一匹");
        Thread t = new Thread() {
            @Override
            public void run() {
                super.run();
                System.out.println("张三帅么 =" + inheritableThreadLocal.get());
                System.out.println("恰饭么 =" + thread.get());;
                inheritableThreadLocal.set("还帅么");
                System.out.println("张三帅么 =" + inheritableThreadLocal.get());
            }
        };
        t.start();
        Thread.sleep(2000);
        System.out.println("张三帅么 =" + inheritableThreadLocal.get());
        inheritableThreadLocal.set("没我帅");
        System.out.println("张三帅么 =" + inheritableThreadLocal.get());
        // 记得把值清空防止内存泄漏
        thread.remove();
        inheritableThreadLocal.remove();
    }

    public static void main(String[] args) throws InterruptedException {
        test();
        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>();
        priorityQueue.offer(8);
        priorityQueue.offer(7);
        priorityQueue.offer(6);
        priorityQueue.offer(5);
        priorityQueue.offer(4);
        priorityQueue.offer(3);
        priorityQueue.offer(2);
        priorityQueue.offer(1);
        priorityQueue.poll();
    }
}
